<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">提交</button>

    <script>
        let btn =document.getElementById('btn');


        function handle() {
            console.log('像后端1发送请求');
            
        }
        btn.addEventListener('click', throttle(handle,1000));


        function throttle(fn,wait) {
            let preTime = 0; //上次执行时间
            return function (...args) { //args是个数组，代表传入的参数
                let nowTime = Date.now(); //当前时间
                if(nowTime - preTime > wait) { //如果当前时间-上次执行时间大于1000ms
                    preTime = nowTime; //更新上次执行时间
                    fn.call(this,...args) //apply和call的区别：apply是传数组，call是传参数
                    
                }
                
            }
        }
    </script>
</body>
</html>